// 角色ID

export const ROLE_ID = {
    ADMIN:{
        desc: '超级管理员',
        value: '1'
    },
    CUSTOM: {
        desc: '客户',
        value: '2'
    },
    PARTNER_TMP: {
        desc: '临时合作伙伴',
        value: '3'
    },
    PARTNER: {
        desc: '合作伙伴',
        value: '4'
    }
}

// 判断当前用户是否管理员
export const currentIsManager = function () {
    let loginUser = this.$store.getters.loginUser;
    if (loginUser.userId === 1) {
        return true;
    }
    return isManagerByRole(loginUser.roles);
}

// 根据角色判断用户是否管理员
export const isManagerByRole = function (roles) {
    if (roles == undefined || roles == [] || roles == ''){
        return false;
    }
    let role = roles[0].roleId;
    return role == ROLE_ID.ADMIN.value ||
        role == ROLE_ID.CUSTOM.value ||
        role == ROLE_ID.PARTNER.value;
}

